package com.system.server.impl;

import com.system.dao.CourseDao;
import com.system.pojo.Course;
import com.system.pojo.SelectedCourse;
import com.system.pojo.SelectedCourseDTO;
import com.system.pojo.UserLogin;
import com.system.server.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author: E-mail:
 * @Version: 创建时间：2019年04月09日21:30
 * @Description: <描述>
 */
@Service
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseDao courseDao;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
    public List<Course> findAll() {
        List<Course> lists = courseDao.selectAll();

        return lists;
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
    public List<Course> findCourseByName(String findByName) {
        List<Course> lists = courseDao.selectCourseByName(findByName);
        return lists;
    }

    @Override
    public List<Course> findCourseByNameAndTeacherName(String findByName, String userLogin) {
        List<Course> lists = courseDao.selectCourseByNameAndTeacherName(findByName,userLogin);
        return lists;
    }

    @Override
    public List<Course> findSelectedCourse(Integer studentID) {
        List<Course> lists = courseDao.selectSelectedCourse(studentID);
        return lists;
    }

    @Override
    public List<Course> findOverSelectedCourse(int studentID) {
        List<Course> lists = courseDao.selectOverSelectedCourse(studentID);
        return lists;
    }

    @Override
    public void outCourse(Integer courseID, String username) {
        courseDao.deleteCourseInfo(courseID,username);
    }
}
